package cn.com.nes.site.service.system.user;

import cn.com.nes.site.entity.vo.user.PushUserInfoVO;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 推送删除用户账号信息
 *
 * @Author: ShenWei
 * @Date: 2024/05/24/15:34
 */
@Service("pushDeleteUserInfoService")
@Slf4j
public class PushDeleteUserInfoService extends PushUserInfoService {

    @Override
    public Integer getPushType() {
        return PushUserInfoVO.PUSH_TYPE_DELETE;
    }

    @Override
    public void pushUserInfo(Map<String, Boolean> checkResult) throws Exception {
        // 解绑易修账号
        if (ObjectUtil.isNotNull(userInfo.getEasyRepairUserId())) {
            unBindEasyRepairAccount();
        }

        // 删除长效管护账号
        if (ObjectUtil.isNotNull(userInfo.getCallCenterUserId())) {
            try {
                callCenterService.deleteCallCenterUser(userInfo.getCallCenterUserId(), Long.valueOf(vo.getCallCenterCompanyId()));
            } catch (Exception e) {
                log.info("删除长效管护用户账号失败,失败原因:{}", e.getMessage());
            } finally {
                systemUserAccountService.bindCallCenterAccount(uuid, null);
            }
        }
    }
}
